<template>
  <div class="hello">
    <message v-for="item in text" :key="item" :con="item"></message>
    <el-input
      type="textarea"
      :rows="2"
      placeholder="请输入评论"
      v-model="textarea">
    </el-input>
    <el-button type="danger" @click="commit">提交</el-button>
  </div>
</template>

<script>
import message from './message.vue'
export default {
  name: 'HelloWorld',
  components: {
    message
  },
  props: {
    msg: String
  },
  data(){
    return {
      textarea:'',
      text:['初始值'],
      oldDate:0
    }
  },
  methods: {
    open() {
        this.$message.error('他妈的空了');
    },
    commit(){
      if(this.textarea === ''){
        this.open()
      }else {
        this.text.push(this.textarea)
        this.textarea = ''
      } 
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.hello {
  width: 100%;
}
</style>
